import { observable, action } from 'mobx';

class AppStore {
  @observable app = {
    token: localStorage.getItem('wl-token-key'),
    userId: localStorage.getItem('wl-user-id-key'),
    loginUser: null
  }

  @action setToken(token) {
    this.app.token = token;
    localStorage.setItem('wl-token-key', token);
  }
  @action setUserId(Id) {
    this.app.userId = Id;
    localStorage.setItem('wl-user-id-key', Id);
  }
  @action logout() {
    this.app.loginUser = null;
    this.app.token = null;
    this.app.userId = null;
    localStorage.removeItem('wl-token-key');
    localStorage.removeItem('wl-user-id-key')
  }
  @action setLoginUser(user) {
    this.app.loginUser = user;
  }
}

export default new AppStore();
